﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Linq;
using MISAPP.Common;
using System.Data.Common;

namespace MISAPP.Classify.DataAccess
{
    public class DA_CIB_Deposit : DA_Matrix
    {
        protected string[] rmAccs = { "'RM合計'", "'存款合計'" };

        protected string[] rmCollect = { "企業金融", "商業金融", "海外業務"
                , "新興金融", "公庫", "NOT FOUND","RM合計" };
        protected string[] accCollect = { "台幣活存","台幣定存","外幣活存"
                ,"外幣定存","公庫存款","存款合計"};
        protected string[] field_vars = { "CAST(1 as float) * SUM(AVG_BAL)/100000000"
,"CASE WHEN SUM(AVG_BAL)=0 THEN 0 ELSE (SUM(AVG_BAL * TRSFR_RATE)/SUM(AVG_BAL)) END"
,"CASE WHEN SUM(AVG_BAL)=0 THEN 0 ELSE (SUM(AVG_BAL * INT_RATE)/SUM(AVG_BAL)) END"
,@"CASE WHEN SUM(AVG_BAL)=0 THEN 0 ELSE ((SUM(AVG_BAL * TRSFR_RATE)/SUM(AVG_BAL)) 
- (SUM(AVG_BAL * INT_RATE)/SUM(AVG_BAL))) END"};

        protected string unionRMACC = @" 
        UNION ALL SELECT '{0}',0,'#','2301',0,0
		UNION ALL SELECT '{0}',0,'#','2321',0,0
		UNION ALL SELECT '{0}',0,'#','2317',0,0
		UNION ALL SELECT '{0}',0,'#','2327',0,0
		UNION ALL SELECT '{0}',0,'#','2305',0,0
";
        //放在合計那個QUERY中
        protected string[] field_cals = {
            "均量","FTP收益率","承作利率","利差"};

        protected Dictionary<string, string> dictTableName = null;
        protected Dictionary<string, string> dictAccNo = null;

        public string[] GetCalFields()
        {
            return field_cals;
        }

        public DA_CIB_Deposit()
        {
            tableName = "cib_deposit";
            dictTableName = new Dictionary<string, string>
            {{"台幣定存-機動","BO1_TD_TWD_V"}
                ,{"公庫定存","BO3_TD_GOV"}
                ,{"台幣活期性存款","DD1_DD_TWD"}
                ,{"公庫國庫存款、支存本行","DD3_DD_CK"}
                ,{"外幣活存","DD4_DD_FX"}
                ,{"公庫集中支付","DD8_DD_GOV"}
                ,{"台幣定存-固定","TD1_TD_TWD_F"}
                ,{"零存整付","TD2_TD_ANNUITY"}
                ,{"如意存款","TD3_TD_ANY"}
                ,{"外幣定存(固定)","TD4_TD_FX"} 
            };
            dictAccNo = new Dictionary<string, string>
            {{"台幣活存","2301,2302,2311,2331"}
             ,{"台幣定存","2321,2328,2335,2336,2333"}
             ,{"外幣活存","2317"}
             ,{"外幣定存","2327"}
             ,{"公庫存款","2305"}
            };
        }

        /// <summary>
        /// 依客群(RM)來產生資料
        /// </summary>
        /// <param name="p_ymList">只有開始和結束月</param>
        /// <param name="p_ymCollect">連續月份</param>
        /// <param name="p_tbl"></param>
        /// <param name="p_acc"></param>
        /// <param name="p_rm"></param>
        /// <param name="p_cur"></param>
        /// <param name="p_option"></param>
        /// <returns></returns>
        public DataTable GetSummaryDataByRM(string[] p_ymList
            , string[] p_ymCollect, string[] p_acc, string[] p_tbl)
        {
            string fldString, fields, sql, accCondition, tblCondition,
            allAccName ,accField,accGroupBy;
            accGroupBy = string.Empty;
            if (p_acc == null)
            {
                //如果沒給值，表示要用全部的acc來做分類
                //p_acc = dictAccNo.Keys.ToArray();
                //2014-03-06 不選，就不要用這來分類
                accField = rmAccs[1];
                allAccName = string.Empty;
                accCondition = string.Empty;
            }
            else
            {
                accField = getAccField(p_acc);
                accGroupBy = "," + accField;
                allAccName = unionRMACC;
                StringBuilder sb = new StringBuilder();
                foreach (string rm in rmCollect)
                {
                    sb.Append(allAccName.Replace("#", rm));
                }
                allAccName = Utility.GetYearMonthString(p_ymCollect, sb.ToString());
                accCondition = getWhereCondition(p_acc, dictAccNo, "A.GL_ACCT_NO");
            }
            tblCondition = p_tbl == null ? string.Empty
                : getWhereCondition(p_tbl, dictTableName, "A.TABLE_NAME");
            
            fldString = ",MAX(CASE WHEN SNAP_YYYYMM = '{0}' THEN AVG_BAL END) [{0}]"
                + Environment.NewLine;
            fields = Utility.GetYearMonthString(p_ymCollect, fldString);
            FillFieldList(p_ymList
                , new string[] { "@YM1", "@YM2" }, "SNAP_YYYYMM");
            GetCriteriaString();
            
            
            

            DataSet ds = new DataSet();
            for (int i = 0; i < field_vars.Length; i++)
            {
                sql = string.Format(getRMSqlStatement()
                    , CriteriaString, fields, field_cals[i]
                    , field_vars[i], accCondition
                    , tblCondition,allAccName,accField
                    , accGroupBy);
                AddParameter(sql);
                ds.Tables.Add(getData());
            }
            return copyDataTable(ds,accCollect,"ACC");
        }

        /// <summary>
        /// 依存款
        /// </summary>
        /// <param name="p_ymList">只有開始和結束月</param>
        /// <param name="p_ymCollect">連續月</param>
        /// <returns></returns>
        public DataTable GetSummaryDataByDeposit(string[] p_ymList
            , string[] p_ymCollect, string[] p_acc, string[] p_tbl,bool p_rm)
        {
            string sql, fldString, fields, accCondition, accField, tblCondition;
            string allAccName,fieldRM;
            if (p_acc == null)
            { 
                //如果沒給值，表示要用全部的acc來做分類
                p_acc = dictAccNo.Keys.ToArray();
            }

            
            tblCondition = p_tbl == null ? string.Empty
               : getWhereCondition(p_tbl, dictTableName, "A.TABLE_NAME");
            GetCriteriaString();
            accCondition = getWhereCondition(p_acc, dictAccNo, "A.GL_ACCT_NO");
            accField = getAccField(p_acc);
            StringBuilder sb = new StringBuilder();
            fldString = ",MAX(CASE WHEN SNAP_YYYYMM = '{0}' THEN AVG_BAL END) [{0}]"
                + Environment.NewLine;

            allAccName = string.Empty;
            if (p_rm == false)
            {
                fieldRM = "'RM合計'";

            }
            else
            {
                fieldRM = "ISNULL(B.RM_GROUP,'NOT FOUND')";
                allAccName = unionRMACC;
                foreach (string rm in rmCollect)
                {
                    sb.Append(allAccName.Replace("#", rm));
                }
                allAccName = Utility.GetYearMonthString(p_ymCollect, sb.ToString());
            }

            fields = Utility.GetYearMonthString(p_ymCollect, fldString);
            
            FillFieldList(p_ymList
                , new string[] { "@YM1", "@YM2" }, "SNAP_YYYYMM");
            DataSet ds = new DataSet();
            for (int i = 0; i < field_vars.Length; i++)
            {
                sql = string.Format(getDepositSqlStatement(), field_vars[i]
                    , fields, accCondition, accField
                    , field_cals[i], CriteriaString, tblCondition
                    , allAccName,fieldRM
                    );
                AddParameter(sql);
                ds.Tables.Add(getData());
            }
            return copyDataTable(ds,rmCollect,"RM_GROUP");
        }

        public DataTable GetSummaryData(string[] p_ymList,string[] p_tbl
            ,string[] p_acc,bool p_rm,bool p_cur)
        {            
            string tblCondition,accCondition,accField,accGroup;
            tblCondition = p_tbl == null ? string.Empty
                :getWhereCondition(p_tbl, dictTableName, "A.TABLE_NAME");
            accCondition = p_acc == null ? string.Empty
                : getWhereCondition(p_acc, dictAccNo, "A.GL_ACCT_NO");
            accGroup = string.IsNullOrEmpty(accCondition) ? "" : getAccField(p_acc) ;
            accField = string.IsNullOrEmpty(accGroup) ? "" : accGroup + "ITEM";
            FillFieldList(p_ymList
                , new string[] { "@YM1", "@YM2" }, "SNAP_YYYYMM");
            GetCriteriaString();
            string sql = string.Format(getSqlStatement()
                , tblCondition 
                , accCondition
                , string.IsNullOrEmpty(tblCondition) ? "": ",A.TABLE_NAME"
                , string.IsNullOrEmpty(accCondition) ? "" : getAccField(p_acc) + "ITEM"
                , string.IsNullOrEmpty(tblCondition) ? "" : ",A.TABLE_NAME"
                , accGroup
                , p_rm == false ? "" : "LEFT OUTER JOIN RM B ON A.ID = B.LNAC_ID"
                , p_rm == false ? "" : ",ISNULL(B.RM_GROUP,'NOT FOUND') RM_GROUP"
                , CriteriaString
                , p_rm == false ? "" : ",RM_GROUP"
                , p_cur == false ? "" : ",CURR_CODE"
                );
            AddParameter(sql);
            return getData();
        }

        protected string getAccField(string[] p_collect)
        {
            StringBuilder sb = new StringBuilder();
            StringBuilder sb2 = new StringBuilder();
            foreach (string acc in p_collect)
            {
                string[] tmps = dictAccNo[acc].ToString().Split(',');
                foreach (string tt in tmps)
                {
                    sb.AppendFormat(",'{0}'", tt);
                }
                //"WHEN SUBSTRING(A.GL_ACCT_NO,1,4) IN ({0}) THEN {1}";
                sb2.AppendFormat(
                    " WHEN SUBSTRING(A.GL_ACCT_NO,1,4) IN ({0}) THEN '{1}' {2}"
                    ,sb.ToString().Substring(1),acc
                    ,Environment.NewLine
                    );
                sb.Remove(0, sb.Length);
            }
            return string.Format("CASE {0} END  "
                ,sb2.ToString());
        }

        protected string getWhereCondition(string[] p_collect
            ,Dictionary<string,string>p_dict,string p_fld)
        {
            StringBuilder sb = new StringBuilder();
            foreach (string str in p_collect)
            {
                string[] tmp = p_dict[str].Split(',');
                foreach (string tt in tmp)
                {
                    sb.AppendFormat(",{0} LIKE '{1}%'", p_fld,tt);
                }                               
            }
            return string.Format(" AND ({0})",
                sb.ToString().Substring(1).Replace(",", " OR "));
        }

        /// <summary>
        /// {0}→YYYYMM 條件
        /// </summary>
        /// <returns></returns>
        protected string getSqlStatement()
        {
            /*             
             * {0} WHERE TABLE_NAME
             * {1} WHERE ACC_NO
             * {2} 把TABLE_NAME當成欄位放上去
             * {3} 把ACC_NO當成欄位放上去
             * {4} 把TABLE_NAME當成GROUP BY 
             * {5} 把ACC_NO當成GROUP BY 
             * {6} RM Table on 
             * {7} RM FIELD =>ISNULL(B.RM_GROUP,'NOT FOUND') RM_GROUP
             * {8} RM condition
             * {9} RM FIELD GROUP BY
             * {10} CURR_CODE field & GROUP BY
             */
            return @"
SELECT
	A.SNAP_YYYYMM
    {3}
    {4}
	,SUM(AVG_BAL) AVG_BAL
	,SUM(CURR_BOOK_BAL) CURR_BOOK_BAL	
	,ROUND(SUM(AVG_BAL * TRSFR_RATE)/SUM(AVG_BAL),2) FTP
	,ROUND(SUM(AVG_BAL * INT_RATE)/SUM(AVG_BAL),2) INT_RATE
	,ROUND((SUM(AVG_BAL * TRSFR_RATE)/SUM(AVG_BAL))
            - (SUM(AVG_BAL * INT_RATE)/SUM(AVG_BAL)) ,2) DIFF_RATE
	{7}
    {10}
FROM CIB_DEPOSIT A {6}
WHERE A.SNAP_YYYYMM BETWEEN @YM1 AND @YM2
    {0}
    {1}
    {8}
GROUP BY A.SNAP_YYYYMM
    {4}
    {5}
    {9}
    {10}
";
        }

        public override DataSet GetCriteria()
        {           
            DataTable dt = new DataTable("ACC_NO");
            DataTable tblDT = new DataTable("TABLE_NAME");
            DataSet ds = new DataSet();
            dt.Columns.Add(new DataColumn("fld1"));
            tblDT.Columns.Add(new DataColumn("fld1"));

            ds.Tables.Add(dictinaryToTable(dt, dictAccNo));
            ds.Tables.Add(dictinaryToTable(tblDT,dictTableName));

            DataTable dtRMGroup = Utility.GetParameterByLevel("CIB", "RM_GROUP");
            DataTable dtRm = new DataTable("RM_GROUP");
            dtRm.Columns.Add("RM_GROUP", typeof(System.String));
            foreach (DataRow rmRow in dtRMGroup.Rows)
            {
                DataRow row1 = dtRm.NewRow();
                row1[0] = rmRow["fldvalue"].ToString();
                dtRm.Rows.Add(row1);
            }

            ds.Tables.Add(dtRm);

            DataTable dtCUR = new DataTable("CURR_CODE");
            dtCUR.Columns.Add("CURR_CODE", typeof(System.String));
            string[] curs = { "TWD","ZAR","CAD","USD","THB","CHF","CNY"
                         ,"GBP","AUD","NZD","EUR","SGD","SEK","JPY","HKD"};
            foreach (string cur in curs)
            {
                DataRow row2 = dtCUR.NewRow();
                row2[0] = cur;
                dtCUR.Rows.Add(row2);
            }
            ds.Tables.Add(dtCUR);
            ds.Tables.Add(Utility.GetYYYYMMRange(Convert.ToDateTime("2012-01-01")));
            DataTable dtY, dt1, dt2;
            dtY = ds.Tables["YYYYMM"];
            dt1 = dtY.Copy(); //dt.Clone();            
            dt1.TableName = "YYYYMM1";
            dt2 = dtY.Copy(); //dt.Clone();
            dt2.TableName = "YYYYMM2";
            ds.Tables.Add(dt1);
            ds.Tables.Add(dt2);
            return ds;
            
        }

        public override string[] GetDistinctField()
        {
            return new string[] { "ACC_NO", "TABLE_NAME","RM_GROUP"
                ,"CURR_CODE","YYYYMM" };
        }

        protected DataTable dictinaryToTable(DataTable p_dt,Dictionary<string,string>p_dict)
        {
            foreach (KeyValuePair<string, string> kv in p_dict)
            {
                DataRow row = p_dt.NewRow();
                row[0] = kv.Key.ToString();
                if (p_dt.Columns.Count > 1)
                {
                    row[1] = kv.Value.ToString();
                }
                p_dt.Rows.Add(row);
            }
            return p_dt;
        }

        /// <summary>
        /// 把兩個dictionary 轉成 一個table
        /// </summary>
        /// <returns></returns>
        public DataTable GetDictionaryTable()
        {
            DataTable dt = new DataTable();
            dt.Columns.Add(new DataColumn("kev"));
            dt.Columns.Add(new DataColumn("value"));
            DataRow row = dt.NewRow();
            row[0] = "會計科目";
            dt.Rows.Add(row);
            dt = dictinaryToTable(dt, dictAccNo);
            row = dt.NewRow();
            row[0] = "Table Name";
            dt.Rows.Add(row);
            dt = dictinaryToTable(dt, dictTableName);
            return dt;
        }

        public override void ResetCriteria()
        {
            base.ResetCriteria();
            tableSchema.Add("RM_GROUP", DbType.String);
        }

        protected string getRMSqlStatement()
        {
            /*
             * {0} RM GROUP 條件
             * {1} ,MAX(CASE WHEN SNAP_YYYYMM = '201201' THEN AVG_BAL END) [201201]
             * {2} 合計名
             * {3} SUM(AVG_BAL) 共有四種要計算
             * {4} 加入會計科目
             * {5} 加入TABLE NAME
             * {6} 顯示RM + 會計名的 UNION ALL
             * EX:
             *         UNION ALL SELECT '201401',0,'企業金融','2301',0,0
		                UNION ALL SELECT '201401',0,'企業金融','2321',0,0
		                UNION ALL SELECT '201401',0,'企業金融','2317',0,0
		                UNION ALL SELECT '201401',0,'企業金融','2327',0,0
		                UNION ALL SELECT '201401',0,'企業金融','2305',0,0
             * {7} 用來分類、Group 也是用這個
             * CASE 
		            WHEN LEFT(A.GL_ACCT_NO,4) IN('2301','2302','2311','2331') THEN '台幣活存'
		            WHEN LEFT(A.GL_ACCT_NO,4) IN('2321','2328','2335','2336','2333') THEN '台幣定存'
		            WHEN LEFT(A.GL_ACCT_NO,4) = '2317' THEN '外幣活存'
		            WHEN LEFT(A.GL_ACCT_NO,4) = '2327' THEN '外幣定存'
		            WHEN LEFT(A.GL_ACCT_NO,4) = '2305' THEN '公庫存款'
		            ELSE 'OTHER'
	            END ACC
             * {8} 因為7的關係，要多加一個給GROUP BY 是用
            */
            return @"
--getRMSqlStatement
SELECT * FROM (
SELECT
	RM_GROUP   
    ,ACC
	{1}
FROM(
	SELECT
		A.SNAP_YYYYMM
		,RM_GROUP 
        ,{7} ACC
		,{3} AVG_BAL
	FROM(
		SELECT
			A.SNAP_YYYYMM		
			,AVG_BAL 
			,ISNULL(B.RM_GROUP,'NOT FOUND') RM_GROUP   
			,SUBSTRING(A.GL_ACCT_NO,1,4) GL_ACCT_NO	
            ,INT_RATE
            ,TRSFR_RATE
		FROM CIB_DEPOSIT A LEFT OUTER JOIN RM B ON A.ID = B.LNAC_ID
		WHERE A.SNAP_YYYYMM BETWEEN @YM1 AND @YM2 
             AND GL_ACCT_NO NOT LIKE '2111%' 
            AND GL_ACCT_NO NOT LIKE '2121%'
			{4}
            {5}
        
            {6}
	)A WHERE 1=1
		{0}
	GROUP BY A.SNAP_YYYYMM,RM_GROUP{8}
)A GROUP BY RM_GROUP ,ACC
UNION ALL
SELECT
    '{2}' 
	,ACC
	{1}
FROM(
SELECT
	A.SNAP_YYYYMM
	,ACC
    ,{3} AVG_BAL
FROM(
	SELECT
		A.SNAP_YYYYMM
		,AVG_BAL
        ,ISNULL(B.RM_GROUP,'NOT FOUND') RM_GROUP 
        ,{7} ACC	
            ,INT_RATE
            ,TRSFR_RATE
	FROM CIB_DEPOSIT A LEFT OUTER JOIN RM B ON A.ID = B.LNAC_ID
	WHERE A.SNAP_YYYYMM BETWEEN @YM1 AND @YM2 
        AND GL_ACCT_NO NOT LIKE '2111%' 
        AND GL_ACCT_NO NOT LIKE '2121%'
		{4}
        {5}
	) A WHERE 1=1
    {0}
GROUP BY A.SNAP_YYYYMM,ACC
)A GROUP BY ACC)A
ORDER BY CASE
    WHEN RM_GROUP = '企業金融' THEN 10
    WHEN RM_GROUP = '商業金融' THEN 20
    WHEN RM_GROUP = '海外業務' THEN 30
    WHEN RM_GROUP = '新興金融' THEN 40
    WHEN RM_GROUP = '公庫' THEN 50
    WHEN RM_GROUP = 'NOT FOUND' THEN 60
    ELSE 70 END


";
        }

        protected string getDepositSqlStatement()
        {
            /*
             * 依存款類型
             * {0}→SUM(AVG_BAL) 要計算的欄位
             * {1}→,MAX(CASE WHEN SNAP_YYYYMM = '201212' THEN AVG_BAL END) [201212]
             * {2}→會計科目條件
             * {3}→用來分類、Group 也是用這個
             * CASE 
		            WHEN LEFT(A.GL_ACCT_NO,4) IN('2301','2302','2311','2331') THEN '台幣活存'
		            WHEN LEFT(A.GL_ACCT_NO,4) IN('2321','2328','2335','2336','2333') THEN '台幣定存'
		            WHEN LEFT(A.GL_ACCT_NO,4) = '2317' THEN '外幣活存'
		            WHEN LEFT(A.GL_ACCT_NO,4) = '2327' THEN '外幣定存'
		            WHEN LEFT(A.GL_ACCT_NO,4) = '2305' THEN '公庫存款'
		            ELSE 'OTHER'
	            END ACC
             * {4}→合計名
             * {5}→RM
             * {6}→TABLE NAME
             * {7}→所有台幣活存台幣定存外幣活存外幣定存公庫存款，全顯示出來
             * {8}→如果沒有選RM，也沒有選存款的就是「RM合計」
            */
            return @"
SELECT * FROM (
SELECT
    ACC    
    ,RM_GROUP	    
	{1}
FROM(
	SELECT
        RM_GROUP		
        ,A.SNAP_YYYYMM	
		,{3} ACC	
		,{0} AVG_BAL
	FROM(
		SELECT
			A.SNAP_YYYYMM		
			,AVG_BAL 
			,{8} RM_GROUP   
			,SUBSTRING(A.GL_ACCT_NO,1,4) GL_ACCT_NO	
            ,INT_RATE
            ,TRSFR_RATE
		FROM CIB_DEPOSIT A LEFT OUTER JOIN RM B ON A.ID = B.LNAC_ID
			WHERE A.SNAP_YYYYMM BETWEEN @YM1 AND @YM2
			  {2}
              {6}  

              {7}
	)A WHERE 1=1
		      {5}
		 GROUP BY RM_GROUP,A.SNAP_YYYYMM
		 ,{3}
)A GROUP BY RM_GROUP,ACC
UNION ALL 
SELECT	
    '{4}'
    ,RM_GROUP
	{1}
FROM( 
	SELECT
        RM_GROUP		
        ,A.SNAP_YYYYMM		
		,{0} AVG_BAL
	FROM(
		SELECT
			A.SNAP_YYYYMM		
			,AVG_BAL 
			,{8} RM_GROUP   
			,SUBSTRING(A.GL_ACCT_NO,1,4) GL_ACCT_NO	
            ,INT_RATE
            ,TRSFR_RATE
		FROM CIB_DEPOSIT A LEFT OUTER JOIN RM B ON A.ID = B.LNAC_ID
			WHERE A.SNAP_YYYYMM BETWEEN @YM1 AND @YM2
			{2}
            {6}

    )A WHERE 1=1
	        {5}
	GROUP BY RM_GROUP,A.SNAP_YYYYMM
)A 	GROUP BY RM_GROUP)A
ORDER BY 
CASE  WHEN ACC ='台幣活存' THEN 10
 WHEN  ACC ='台幣定存' THEN 20
 WHEN  ACC ='外幣活存' THEN 30
 WHEN  ACC ='外幣定存' THEN 40
 WHEN  ACC ='公庫存款' THEN 50
 ELSE 60
 END
";
        }

        protected DataTable copyDataTable(DataSet p_ds,string[] p_collect,string p_fldName)
        {            
            DataTable newDT = new DataTable();
            foreach (DataColumn col in p_ds.Tables[0].Columns)
            {
                DataColumn newCol = new DataColumn();
                newCol.ColumnName = col.ColumnName;
                newCol.DataType = col.DataType;
                newDT.Columns.Add(newCol);
            }
            DataTable newDT2 = newDT.Copy();
            foreach (DataTable dt in p_ds.Tables)
            {
                foreach (DataRow row in dt.Rows)
                {
                    DataRow newRow = newDT.NewRow();
                    for (int i = 0; i < dt.Columns.Count; i++)
                    {
                        newRow[i] = row[i];
                    }
                    newDT.Rows.Add(newRow);                
                }
            }
            foreach (string cllt in p_collect)
            {
                IEnumerable<DataRow> selectRow =
                    from aa in newDT.AsEnumerable()
                    where (aa.Field<string>(p_fldName) == cllt)
                    select aa;
                if (selectRow.Count() > 0)
                {
                    foreach (DataRow row in selectRow)
                    {
                        DataRow newRow = newDT2.NewRow();
                        for (int i = 0; i < newDT2.Columns.Count; i++)
                        {
                            newRow[i] = row[i];
                        }
                        newDT2.Rows.Add(newRow);
                    }
                }
            }
            

            return newDT2;
        }
    }
}
